//为字符串增加trim方法，使用正则表达式截取空格
String.prototype.trim = function(){
	return this.replace(/^\s*/,"").replace(/\s*$/,"");
}
//注册表单提交事件
var checkRegisterForm = function(){
	//alert("我点击了注册");
	//访问注册登录表单
	var registerForm = document.getElementById("register_form_id");
	//错误字符串
	var errStr = "";
	//当用户名为空时
	if(registerForm.account.value == null || registerForm.account.value.trim() == ""){
		errStr += "\n账号不能为空！";
		registerForm.account.focus();
	}
	//当密码为空时
	if(registerForm.password.value == null || registerForm.password.value.trim() == ""){
		errStr += "\n密码不能为空！";
		registerForm.password.focus();
	}
	//当错误字符串不为空时,则表明校验出错
	if(errStr != ""){
		//弹出出错信息
		alert(errStr);
		//返回false,用于阻止表单提交
		return false;
	}
}

//登录表单点击事件
var checkLoginForm = function(){
	//我点击了登录
	//alert("我点击了登录");
	var loginForm = document.getElementById("login_form_id");
	//错误字符串
	var errStr = "";
	//当用户名为空时
	if(loginForm.account.value == null || loginForm.account.value.trim() == ""){
		errStr += "\n账号不能为空！";
		loginForm.account.focus();
	}
	//当密码为空时
	if(loginForm.password.value == null || loginForm.password.value.trim() == ""){
		errStr += "\n密码不能为空！";
		loginForm.password.focus();
	}
	//当错误字符串不为空时,则表明校验出错
	if(errStr != ""){
		//弹出出错信息
		alert(errStr);
		//返回false,用于阻止表单提交
		return false;
	}	
}

/*
//注册
var register = function(){
	//显示注册div
	document.getElementById("register_id").style.display = "block";
	//隐藏登录div
	document.getElementById("login_id").style.display = "none";
}
//登录
var login = function(){
	//显示登录div
	document.getElementById("login_id").style.display = "block";
	//隐藏注册div
	document.getElementById("register_id").style.display = "none";
}*/


